]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
panel: Add closeQuickSettings() method
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 30 Jul 2022 00:24:17 +0000 (02:24 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 2 Aug 2022 16:05:28 +0000 (16:05 +0000)
Like the aggregate menu currently, the quick settings menu will
eventually contain some items that should dismiss the menu. And
as those items may appear in child menus or otherwise be nested,
a public method on a global object is more convenient than handing
the main menu down the hierarchy.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2392>

js/ui/panel.js

index 850d4f06c168ba87b6f03c17add00c6ed26e7226..d259fcbb23146b3d49ac0bd842c1c3cef0d92ddc 100644 (file)
@@ -643,6 +643,16 @@ class Panel extends St.Widget {
             menu.actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
     }
 
+    _closeMenu(indicator) {
+        if (!indicator || !indicator.mapped)
+            return; // menu not supported by current session mode
+
+        if (!indicator.reactive)
+            return;
+
+        indicator.menu.close();
+    }
+
     toggleAppMenu() {
         this._toggleMenu(this.statusArea.appMenu);
     }
@@ -652,15 +662,11 @@ class Panel extends St.Widget {
     }
 
     closeCalendar() {
-        let indicator = this.statusArea.dateMenu;
-        if (!indicator) // calendar not supported by current session mode
-            return;
-
-        let menu = indicator.menu;
-        if (!indicator.reactive)
-            return;
+        this._closeMenu(this.statusArea.dateMenu);
+    }
 
-        menu.close();
+    closeQuickSettings() {
+        this._closeMenu(this.statusArea.quickSettings);
     }
 
     set boxOpacity(value) {